package com.ff.discounts.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

/**
 * 所有Fragment 父类
 * @author: fufang
 * @date: 2023/10/17
 */
abstract class BaseFragment :Fragment() {
    /**
    * 找控件
    */
    protected open fun initViews(){}

    /**
    * 设置数据
    */
    protected open fun initDatum(){}

    /**
    * 设置监听器
    */
    protected open fun initListeners(){}

    /**
     * 返回要显示的控件
     */

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // 获取view
        return getLayoutView(inflater, container, savedInstanceState)
    }

    abstract fun getLayoutView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View?

    /**
     * @description view 创建了
     * @param
     * @return
     */

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initViews()
        initDatum()
        initListeners()
    }
}
